home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 44 / PC Actual CD 44.iso / Linux / Cygwin / full.exe / Disk1 / data1.cab / Tools / H-i586-cygwin32 / i586-cygwin32 / include / mingw32 / time.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-12-04  |  4.1 KB  |  170 lines

  1. /* 
  2.  * time.h
  3.  *
  4.  * Date and time functions and types.
  5.  *
  6.  * This file is part of the Mingw32 package.
  7.  *
  8.  * Contributors:
  9.  *  Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
  10.  *
  11.  *  THIS SOFTWARE IS NOT COPYRIGHTED
  12.  *
  13.  *  This source code is offered for use in the public domain. You may
  14.  *  use, modify or distribute it freely.
  15.  *
  16.  *  This code is distributed in the hope that it will be useful but
  17.  *  WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
  18.  *  DISCLAMED. This includes but is not limited to warranties of
  19.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  20.  *
  21.  * $Revision: 1.3 $
  22.  * $Author: noer $
  23.  * $Date: 1998/10/20 01:24:49 $
  24.  *
  25.  */
  26.  
  27. #ifndef    _TIME_H_
  28. #define    _TIME_H_
  29.  
  30. #define __need_wchar_t
  31. #define __need_size_t
  32. #ifndef RC_INVOKED
  33. #include <stddef.h>
  34. #endif    /* Not RC_INVOKED */
  35.  
  36. /*
  37.  * Need a definition of time_t.
  38.  */
  39. #include <sys/types.h>
  40.  
  41. /*
  42.  * Number of clock ticks per second. A clock tick is the unit by which
  43.  * processor time is measured and is returned by 'clock'.
  44.  */
  45. #define    CLOCKS_PER_SEC    1000.0
  46. #define    CLK_TCK        CLOCKS_PER_SEC
  47.  
  48.  
  49. #ifndef RC_INVOKED
  50.  
  51. /*
  52.  * A type for storing the current time and date. This is the number of
  53.  * seconds since midnight Jan 1, 1970.
  54.  * NOTE: Normally this is defined by the above include of sys/types.h
  55.  */
  56. #ifndef _TIME_T_
  57. #define _TIME_T_
  58. typedef    long    time_t;
  59. #endif
  60.  
  61. /*
  62.  * A type for measuring processor time (in clock ticks).
  63.  */
  64. #ifndef _CLOCK_T_
  65. #define _CLOCK_T_
  66. typedef    long    clock_t;
  67. #endif
  68.  
  69.  
  70. /*
  71.  * A structure for storing all kinds of useful information about the
  72.  * current (or another) time.
  73.  */
  74. struct tm
  75. {
  76.     int    tm_sec;        /* Seconds: 0-59 (K&R says 0-61?) */
  77.     int    tm_min;        /* Minutes: 0-59 */
  78.     int    tm_hour;    /* Hours since midnight: 0-23 */
  79.     int    tm_mday;    /* Day of the month: 1-31 */
  80.     int    tm_mon;        /* Months *since* january: 0-11 */
  81.     int    tm_year;    /* Years since 1900 */
  82.     int    tm_wday;    /* Days since Sunday (0-6) */
  83.     int    tm_yday;    /* Days since Jan. 1: 0-365 */
  84.     int    tm_isdst;    /* +1 Daylight Savings Time, 0 No DST,
  85.                  * -1 don't know */
  86. };
  87.  
  88. #ifdef    __cplusplus
  89. extern "C" {
  90. #endif
  91.  
  92. clock_t    clock ();
  93. time_t    time (time_t* tp);
  94. double    difftime (time_t t2, time_t t1);
  95. time_t    mktime (struct tm* tmsp);
  96.  
  97. /*
  98.  * These functions write to and return pointers to static buffers that may
  99.  * be overwritten by other function calls. Yikes!
  100.  *
  101.  * NOTE: localtime, and perhaps the others of the four functions grouped
  102.  * below may return NULL if their argument is not 'acceptable'. Also note
  103.  * that calling asctime with a NULL pointer will produce an Invalid Page
  104.  * Fault and crap out your program. Guess how I know. Hint: stat called on
  105.  * a directory gives 'invalid' times in st_atime etc...
  106.  */
  107. char*        asctime (const struct tm* tmsp);
  108. char*        ctime (const time_t* tp);
  109. struct tm*    gmtime (const time_t* tm);
  110. struct tm*    localtime (const time_t* tm);
  111.  
  112.  
  113. size_t    strftime (char* caBuffer, size_t sizeMax, const char* szFormat,
  114.           const struct tm* tpPrint);
  115.  
  116. size_t    wcsftime (wchar_t* wcaBuffer, size_t sizeMax,
  117.           const wchar_t* wsFormat, const struct tm* tpPrint);
  118.  
  119. #ifndef __STRICT_ANSI__
  120. extern void    _tzset (void);
  121.  
  122. #ifndef _NO_OLDNAMES
  123. extern void    tzset (void);
  124. #endif
  125.  
  126. #endif    /* Not __STRICT_ANSI__ */
  127.  
  128. /*
  129.  * _daylight: non zero if daylight savings time is used.
  130.  * _timezone: difference in seconds between GMT and local time.
  131.  * _tzname: standard/daylight savings time zone names (an array with two
  132.  *          elements).
  133.  */
  134. #ifdef __MSVCRT__
  135.  
  136. extern int*    __p__daylight (void);
  137. extern long*    __p__timezone (void);
  138. extern char**    __p__tzname (void);
  139.  
  140. #define _daylight    (*__p__daylight())
  141. #define _timezone    (*__p__timezone())
  142. #define _tzname        (__p__tzname())
  143.  
  144. #else /* not __MSVCRT (ie. crtdll) */
  145.  
  146. extern int*    __imp__daylight_dll;
  147. extern long*    __imp__timezone_dll;
  148. extern char**    __imp__tzname;
  149.  
  150. #define _daylight    (*__imp__daylight_dll)
  151. #define _timezone    (*__imp__timezone_dll)
  152. #define _tzname        (__imp__tzname)
  153.  
  154. #endif /* not __MSVCRT__ */
  155.  
  156. #ifndef _NO_OLDNAMES
  157. #define    daylight    _daylight
  158. /* NOTE: timezone not defined because it would conflict with sys/timeb.h */
  159. #define    tzname        _tzname
  160. #endif    /* Not _NO_OLDNAMES */
  161.  
  162. #ifdef    __cplusplus
  163. }
  164. #endif
  165.  
  166. #endif    /* Not RC_INVOKED */
  167.  
  168. #endif    /* Not _TIME_H_ */
  169.  
  170.